how to reverse a string in java using for loop